/*
 *   Copyright (C) <2009>
 *
 *   <Sandeep K Sinha>
 *   <Rishi B Agrawal> <Vineet Agarwal> <Rohit Vashist>
 *	<Rohit K Sharma> <Sneha Hendre>
 *
 *   <sandeepksinha@gmail.com> <rishi.b.agrawal@gmail.com> <checkout.vineet@gmail.com>
 *   <rohit.k.vashist@gmail.com> <imreckless@gmail.com> <sneha.hendre@gmail.com>
 *
 *   This program is free software: you can redistribute it and/or modify it
 *   under the terms of the GNU General Public License as published by the
 *   Free Software Foundation, either version 3 of the License, or (at your
 *   option) any later version->
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE->  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
#ifndef OHSM_K_H
#define OHSM_K_H

#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/types.h>
#include <linux/writeback.h>

#define ohsm_debug(loglevel, f, a...)		\
    do {					\
      if ((ohsm_enable_debug&(loglevel))&((1<<OHSM_LOG_MAX)-1)) {		\
	printk("OHSM-Debug : %s : (%s, %d) : %s:",			\
	       ohsm_log_table[__ffs(loglevel)].log_name, \
	       __FILE__, __LINE__, __func__);				\
	printk(f, ##a);							\
      }									\
    } while (0);

#define ohsm_error(loglevel, f, a...)					\
    do {								\
	printk(KERN_CRIT "OHSM-Error : %s : (%s, %d) : %s:",		\
	       ohsm_log_table[__ffs(loglevel)].log_name, \
	       __FILE__, __LINE__, __func__);				\
	printk(f, ##a);							\
    } while (0);

#define OHSM_ADMIN_ERROR 1
typedef unsigned char map_info_ready_t;
typedef unsigned char table_ready_t;

char ohsm_mountpoint[OHSM_MAX_MNTPT_LEN];
int ohsm_relocating;
unsigned int Major;

map_info_ready_t mapper_flag;
table_ready_t map_table_flag;

struct ohsm_struct_rules *rules;
struct ext2_sb_info *ohsm_sbi;
struct ohsm_relocatable_inode *list_inodes;
struct ohsm_struct_for_ioctl *ohsm_admin_info;
struct ohsm_struct_rules *reloc_policy_t;
struct ohsm_device_info *devices;
struct ohsm_tier_dev_info *ohsm_dev_info;
struct ohsm_allocation_policy *ohsm_allocpol;
struct ohsm_reloc_policy *ohsm_relocpol;
extern int ohsm_enabled;
extern unsigned long sam[OHSM_MAX_TIER_ALLOWED][OHSM_MAX_PV_PER_LVM * 2 + 1];
extern struct ohsm_allocation_policy *ohsm_alloc_policy;
extern struct super_block *ohsm_sb;
extern struct buffer_head *read_inode_bitmap (struct super_block *, unsigned long);
void debug_print_sam(void);

int ohsm_sync_inode(struct inode *inode)
{
	struct writeback_control wbc = {
		.sync_mode = WB_SYNC_ALL,
		.nr_to_write = 0,
	};
	return sync_inode(inode, &wbc);
}
unsigned char ohsm_get_tier (struct dentry *);
extern unsigned char (*ohsm_get_tier_fptr)(struct inode *, struct dentry *, int);

#endif
